import axios from "axios";
import {Dispatch} from "redux"

export let get_list = () => {
  return async (dispatch: any) => {
    let { data } = await axios.get("/api/list");
    dispatch({
      type: "GET_LIST",
      payload: data.list,
    });
  };
};
export let check_DATA=(index:any)=>{
  console.log(index);
  
    return {
        type: "CHECK_DATA",
        payload: index
    }
   
}

export let user_login = (values:object) =>{
  return async (dispatch:Dispatch) => {
      let {data} = await axios.get("/api/login",{params:values})
      console.log(data);
      dispatch({
          type:"USER_LOGIN",
          payload:Object.assign({},values,{...data})
      })
  }
}

export let user_register = (values:object) =>{
  return async () => {
      let {data} = await axios.get("/api/reg",{params:values})
      console.log(data);
      
  }
}